
#include "UnitTestMultiGPU.hpp"

#ifndef FRAME_COUNT
#define FRAME_COUNT 1
#endif

int main( int argc, char * argv[] )
{
	std::cout << "allocate pipeline " << "UnitTestMultiGPU" << std::endl;
	UnitTestMultiGPU * pipeline = new UnitTestMultiGPU();
	std::cout << "initialize OpenCL " << "UnitTestMultiGPU" << std::endl;
	pipeline->initializeOpenCL();
	std::cout << "intiialize pipeline " << "UnitTestMultiGPU" << std::endl;
	pipeline->initialize();
	std::cout << "UnitTestMultiGPU" << " runToCompletion" << std::endl;

#ifdef _WIN32
	__int64 freq, tStart, tStop;
	unsigned long TimeDiff;
	// Get the frequency of the hi-res timer
	QueryPerformanceFrequency((LARGE_INTEGER*)&freq);
	// Assuming that has worked you can then use hi-res timer
	QueryPerformanceCounter((LARGE_INTEGER*)&tStart);
#else
	// to do
#endif

	int i;
	for( i = 0; i < FRAME_COUNT; ++i ){
		pipeline->runToCompletion( true );
	}//for

#ifdef _WIN32
	// Perform operations that require timing
	QueryPerformanceCounter((LARGE_INTEGER*)&tStop);
	// Calculate time difference
	TimeDiff = (unsigned long)(((tStop - tStart) * 1000000) / freq);
	std::cout << "Elapsed time frame " << i << " is " << TimeDiff 
		<< " microseconds for " << FRAME_COUNT << " frames" << std::endl;
	double td = (double)TimeDiff;
	double tdPerFrame = td / FRAME_COUNT;
	double fps = FRAME_COUNT * 1000000.0 / td;
	std::cout << "Frames per second = " << fps << ", microseconds per frame = " << tdPerFrame << std::endl;
#else
	// to do
#endif

	std::cout << "UnitTestMultiGPU" << " testToCompletion" << std::endl;
	pipeline->testToCompletion( true );
	std::cout << "UnitTestMultiGPU" << " captureToCompletion" << std::endl;
	pipeline->captureToCompletion( true );
	std::cout << "completed pipeline " << "UnitTestMultiGPU" << std::endl;
	delete pipeline;
	std::cout << "deleted pipeline" << std::endl;
	return 0;
}
